package com.Eastiy.EXO.View;

import android.animation.Animator;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver;
import android.view.animation.AlphaAnimation;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.EditText;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class ASUI {
    public static String[] clm = daycm;
    public static String[][] colors;
    public static String[] daycm = {"#ffffff", "#f9f9f9", "#f4f4f4", "#e9e9e9", "#000000", "#9198e5", "#000000"};
    public static ViewTreeObserver.OnGlobalLayoutListener globallayoutlinstener = null;
    public static String[] nitcm = {"#000000", "#222222", "#333333", "#3f3f3f", "#eeeeee", "#e66465", "#ffffff"};

    static {
        String[] strArr = {"§2", "</font><font color=#72EEBC>"};
        colors = new String[][]{new String[]{" ", " &nbsp;"}, new String[]{"\n", "<br/>"}, new String[]{"§l", "</b><b>"}, new String[]{"§m", "</del><del>"}, new String[]{"§n", "</ins><ins>"}, new String[]{"§o", "</i><i>"}, new String[]{"§r", "</font></b></del></ins></i>"}, new String[]{"§0", "</font><font color=#000000>"}, new String[]{"§1", "</font><font color=#0000AA>"}, strArr, new String[]{"§3", "</font><font color=#00AAAA>"}, new String[]{"§4", "</font><font color=#FFA39E>"}, new String[]{"§5", "</font><font color=#FB98BF>"}, new String[]{"§6", "</font><font color=#B0E2FF>"}, new String[]{"§7", "</font><font color=#d3cad3>"}, new String[]{"§8", "</font><font color=#555555>"}, new String[]{"§9", "</font><font color=#5555FF>"}, new String[]{"§a", "</font><font color=#55FF55>"}, new String[]{"§b", "</font><font color=#70E3FF>"}, new String[]{"§c", "</font><font color=#FF5555>"}, new String[]{"§d", "</font><font color=#e9a2eb>"}, new String[]{"§e", "</font><font color=#ffcf75>"}, new String[]{"§f", "</font><font color=#FFFFFF>"}};
    }

    public static boolean CheckFiles(String str) {
        return new File(str).exists();
    }

    public static void Colorchangeanimation(View view, Object obj, int i) {
        ObjectAnimator ofInt = ObjectAnimator.ofInt(view, "backgroundColor", new int[]{((Integer) obj).intValue()});
        ofInt.setDuration((long) i);
        ofInt.setEvaluator(new ArgbEvaluator());
        ofInt.start();
    }

    public static void Displacementanimation(View view, String str, int[] iArr, int i) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, str, new float[]{Float.valueOf((float) iArr[0]).floatValue(), Float.valueOf((float) iArr[1]).floatValue(), Float.valueOf((float) iArr[2]).floatValue()});
        ofFloat.setDuration((long) i);
        ofFloat.start();
    }

    public static Spanned FontColor(String str) {
        for (int i = 0; i < colors.length; i++) {
            str = join(str.split(colors[i][0]), colors[i][1]);
        }
        return Html.fromHtml(str);
    }

    public static String GETmanufacturer() {
        return Build.MANUFACTURER;
    }

    public static String GetAndroidEdition() {
        return Build.VERSION.RELEASE;
    }

    public static String GetIMEI(Context context) {
        return ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
    }

    public static String GetQQ() {
        return getQQList().split(",")[0].replace("[", "");
    }

    public static String GetVersionnumber() {
        return Build.DISPLAY;
    }

    public static String Getname() {
        return Build.MODEL;
    }

    public static void InputData(String str, String str2) {
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(str);
            fileOutputStream.write(str2.getBytes());
            fileOutputStream.close();
        } catch (FileNotFoundException | IOException e) {
        }
    }

    public static EditText NewET(Context context, String str, String str2, int i, String str3, boolean z) {
        EditText editText = new EditText(context);
        editText.setHint(str);
        editText.setText(str2);
        editText.setTextSize((float) i);
        editText.setTextColor(Color.parseColor(str3));
        if (!z) {
            editText.setBackground((Drawable) null);
        }
        return editText;
    }

    public static GradientDrawable Portable(Object[] objArr, Object obj, Object obj2) {
        Object[] objArr2 = new Object[0];
        String[] strArr = (String[]) objArr;
        for (int i = 1; i < strArr.length; i++) {
            push(objArr2, new Integer(hexColor(strArr[i])));
        }
        return new roundRect(objArr2, obj, strArr[0], obj2);
    }

    public static int PostHtml(String str) throws Exception {
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        httpURLConnection.setConnectTimeout(5000);
        httpURLConnection.setRequestMethod("GET");
        return httpURLConnection.getResponseCode() == 200 ? 1 : 0;
    }

    public static String ReadData(String str) {
        String str2 = "";
        File file = new File(str);
        if (!file.isDirectory()) {
            try {
                FileInputStream fileInputStream = new FileInputStream(file);
                if (fileInputStream != null) {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        str2 = new StringBuffer().append(str2).append(new StringBuffer().append(readLine).append("\n").toString()).toString();
                    }
                    fileInputStream.close();
                }
            } catch (FileNotFoundException e) {
            } catch (IOException e2) {
            }
        }
        return str2;
    }

    public static void Rotationanimation(View view, String str, Object[] objArr, int i) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, str, new float[]{Float.valueOf(objArr[0].floatValue()).floatValue(), Float.valueOf(objArr[1].floatValue()).floatValue(), Float.valueOf(objArr[2].floatValue()).floatValue()});
        ofFloat.setDuration((long) i);
        ofFloat.start();
    }

    public static void Transparentanimation(View view, Object[] objArr, int i) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "alpha", new float[]{Float.valueOf(objArr[0].floatValue()).floatValue(), Float.valueOf(objArr[1].floatValue()).floatValue(), Float.valueOf(objArr[2].floatValue()).floatValue()});
        ofFloat.setDuration((long) i);
        ofFloat.start();
    }

    public static AlphaAnimation UIFadein(View view, int i, int i2, int i3) {
        AlphaAnimation alphaAnimation = new AlphaAnimation((float) ((int) (((double) i) * 0.01d)), (float) ((int) (((double) i2) * 0.01d)));
        alphaAnimation.setDuration((long) i3);
        if (view != null) {
            view.startAnimation(alphaAnimation);
        }
        return alphaAnimation;
    }

    public static TranslateAnimation UILevel(View view, int i, int i2, int i3, Object obj) {
        return UIMove(view, i, i2, 0, 0, i3, obj);
    }

    public static TranslateAnimation UIMove(View view, int i, int i2, int i3, int i4, int i5, Object obj) {
        int i6 = (obj == null || obj == new Integer(0)) ? 1 : obj == new Integer(1) ? 2 : 0;
        TranslateAnimation translateAnimation = new TranslateAnimation(i6, (float) ((int) (((double) i) * 0.01d)), i6, (float) ((int) (((double) i2) * 0.01d)), i6, (float) ((int) (((double) i3) * 0.01d)), i6, (float) ((int) (((double) i4) * 0.01d)));
        translateAnimation.setDuration((long) i5);
        if (view != null) {
            view.startAnimation(translateAnimation);
        }
        return translateAnimation;
    }

    public static TranslateAnimation UIPlumb(View view, int i, int i2, int i3, Object obj) {
        return UIMove(view, 0, 0, i, i2, i3, obj);
    }

    public static ViewTreeObserver.OnGlobalLayoutListener UIReveal(View view, int i, int i2, int i3, int i4, int i5) {
        globallayoutlinstener = new ViewTreeObserver.OnGlobalLayoutListener(view, i, i2, i3, i4, i5) {
            private final int val$endr;
            private final int val$startr;
            private final int val$time;
            private final View val$view;
            private final int val$x;
            private final int val$y;

            {
                this.val$view = r1;
                this.val$x = r2;
                this.val$y = r3;
                this.val$startr = r4;
                this.val$endr = r5;
                this.val$time = r6;
            }

            @Override
            public void onGlobalLayout() {
                Animator createCircularReveal = ViewAnimationUtils.createCircularReveal(this.val$view, this.val$x, this.val$y, Float.valueOf((float) this.val$startr).floatValue(), Float.valueOf((float) this.val$endr).floatValue());
                createCircularReveal.setDuration((long) this.val$time);
                createCircularReveal.start();
                this.val$view.getViewTreeObserver().removeOnGlobalLayoutListener(ASUI.globallayoutlinstener);
            }
        };
        view.setVisibility(0);
        view.getViewTreeObserver().addOnGlobalLayoutListener(globallayoutlinstener);
        return globallayoutlinstener;
    }

    public static RotateAnimation UIRotate(View view, int i, int i2, int i3, int i4, int i5, Object obj) {
        int i6 = (obj == null || obj == new Integer(0)) ? 1 : obj == new Integer(1) ? 2 : 0;
        RotateAnimation rotateAnimation = new RotateAnimation((float) i, (float) i2, i6, (float) ((int) (((double) i3) * 0.01d)), i6, (float) ((int) (((double) i4) * 0.01d)));
        rotateAnimation.setDuration((long) i5);
        rotateAnimation.setFillAfter(true);
        if (view != null) {
            view.startAnimation(rotateAnimation);
        }
        return rotateAnimation;
    }

    public static ScaleAnimation UIShrink(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, Object obj) {
        int i8 = (obj == null || obj == new Integer(0)) ? 1 : obj == new Integer(1) ? 2 : 0;
        ScaleAnimation scaleAnimation = new ScaleAnimation((float) ((int) (((double) i) * 0.01d)), (float) ((int) (((double) i2) * 0.01d)), (float) ((int) (((double) i3) * 0.01d)), (float) ((int) (((double) i4) * 0.01d)), i8, (float) ((int) (((double) i5) * 0.01d)), i8, (float) ((int) (((double) i6) * 0.01d)));
        scaleAnimation.setDuration((long) i7);
        if (view != null) {
            view.startAnimation(scaleAnimation);
        }
        return scaleAnimation;
    }

    public static ScaleAnimation UIZoom(View view, int i, int i2, int i3, Object obj) {
        return UIShrink(view, i, i2, i, i2, 50, 50, i3, obj);
    }

    public static void Waterdropanimation(View view, int i) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "scaleX", new float[]{(float) 1, 0.8f, 1.3f, 0.9f, (float) 1});
        ofFloat.setDuration((long) i);
        ofFloat.start();
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(view, "scaleY", new float[]{(float) 1, 0.8f, 1.3f, 0.9f, (float) 1});
        ofFloat2.setDuration((long) i);
        ofFloat2.start();
    }

    public static void Zoomanimation(View view, Object[] objArr, int i) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "scaleX", new float[]{Float.valueOf(objArr[0].floatValue()).floatValue(), Float.valueOf(objArr[1].floatValue()).floatValue(), Float.valueOf(objArr[2].floatValue()).floatValue()});
        ofFloat.setDuration((long) i);
        ofFloat.start();
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(view, "scaleY", new float[]{Float.valueOf(objArr[0].floatValue()).floatValue(), Float.valueOf(objArr[1].floatValue()).floatValue(), Float.valueOf(objArr[2].floatValue()).floatValue()});
        ofFloat2.setDuration((long) i);
        ofFloat2.start();
    }

    public static void ensureCapacity(Object[] objArr, int i, int i2) {
        int i3 = 10;
        int i4 = i - 5;
        if (i4 <= 0) {
            throw new IllegalArgumentException();
        } else if (objArr == null) {
            if (10 >= i4) {
                i4 = 10;
            }
            Object[] objArr2 = new Object[i4];
        } else {
            int length = objArr.length;
            if (length < i4) {
                if (length > 5) {
                    i3 = length * 2;
                }
                if (i3 >= i4) {
                    i4 = i3;
                }
                Object[] objArr3 = new Object[i4];
                if (i2 > 5) {
                    System.arraycopy(objArr, 0, objArr3, 0, i2 - 5);
                }
            }
        }
    }

    public static String getHtml(String str) throws Exception {
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        httpURLConnection.setConnectTimeout(5000);
        httpURLConnection.setRequestMethod("GET");
        if (httpURLConnection.getResponseCode() == 200) {
            return new String(read(httpURLConnection.getInputStream()), "UTF-8");
        }
        return null;
    }

    public static Bitmap getImage(String str) throws Exception {
        try {
            URL url = new URL(str);
            String headerField = url.openConnection().getHeaderField(0);
            if (headerField.indexOf("200") >= 0) {
                return BitmapFactory.decodeStream(url.openStream());
            }
            throw new Exception(new StringBuffer().append("图片文件不存在或路径错误，错误代码：").append(headerField).toString());
        } catch (IOException e) {
            throw new Exception(e.getMessage());
        }
    }

    public static String getQQList() {
        ArrayList arrayList = new ArrayList();
        File[] listFiles = new File(Environment.getExternalStorageDirectory(), "Android/data/com.tencent.mobileqq/Tencent/MobileQQ/").listFiles();
        if (listFiles == null) {
            return "无";
        }
        for (int i = 0; listFiles.length > i; i++) {
            if (listFiles[i].isDirectory() && listFiles[i].getName().matches("^[0-9]+$")) {
                arrayList.add(listFiles[i].getName());
            }
        }
        return arrayList.toString();
    }

    public static Bitmap getURLimage(String str) {
        Bitmap bitmap = null;
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
            httpURLConnection.setConnectTimeout(6000);
            httpURLConnection.setDoInput(true);
            httpURLConnection.setUseCaches(false);
            httpURLConnection.connect();
            InputStream inputStream = httpURLConnection.getInputStream();
            bitmap = BitmapFactory.decodeStream(inputStream);
            inputStream.close();
            return bitmap;
        } catch (Exception e) {
            e.printStackTrace();
            return bitmap;
        }
    }

    public static Bitmap getbitmap(String str) {
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
            httpURLConnection.setDoInput(true);
            httpURLConnection.connect();
            InputStream inputStream = httpURLConnection.getInputStream();
            Bitmap decodeStream = BitmapFactory.decodeStream(inputStream);
            inputStream.close();
            return decodeStream;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static int geth(View view) {
        view.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
        return view.getMeasuredHeight();
    }

    public static int getw(View view) {
        view.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
        return view.getMeasuredWidth();
    }

    public static int hexColor(String str) {
        return Color.parseColor(str);
    }

    public static void hint(Context context, String str) {
        int i = context.getResources().getDisplayMetrics().heightPixels;
        Toast makeText = Toast.makeText(context, str, 1);
        NewView newView = new NewView(context, new Integer(-2), new Integer(-2), "CC", new Integer(1), 2, "#ffffff", new Integer(30), (View.OnClickListener) null);
        NewView newView2 = new NewView(context, new Integer(-2), new Integer(-2), "CC", new Integer(1), 1, "#ffffff", new Integer(30), (View.OnClickListener) null);
        NewText newText = new NewText(context, str, "CC", 13, "#000000");
        newText.setPadding(30, 30, 30, 30);
        newView.setElevation((float) 80);
        newView2.setElevation((float) 80);
        makeText.setView(newView);
        newView.addView(newView2);
        newView2.addView(newText);
        makeText.setGravity(81, 0, (int) (((double) i) * 0.24d));
        UIZoom(newText, 110, 100, 300, (Object) null);
        new Handler().postDelayed(new Runnable(newView, i, newText) {
            private final int val$h;
            private final NewText val$txt;
            private final NewView val$txtv;

            {
                this.val$txtv = r1;
                this.val$h = r2;
                this.val$txt = r3;
            }

            @Override
            public void run() {
                ASUI.UIMove(this.val$txtv, 0, 0, (int) (((double) this.val$h) * 0.24d), 0, 300, (Object) null);
                ASUI.UIMove(this.val$txt, 0, 0, (int) (((double) this.val$h) * 0.24d), 0, 300, (Object) null);
            }
        }, (long) 50);
        new Handler().postDelayed(new Runnable(newText, i, newView2, makeText) {
            private final int val$h;
            private final Toast val$toast;
            private final NewText val$txt;
            private final NewView val$txtv1;

            {
                this.val$txt = r1;
                this.val$h = r2;
                this.val$txtv1 = r3;
                this.val$toast = r4;
            }

            @Override
            public void run() {
                ASUI.UIMove(this.val$txt, 0, 0, (int) (((double) this.val$h) * 0.14d), 0, 200, (Object) null);
                ASUI.UIMove(this.val$txtv1, 0, 0, 0, (int) (((double) this.val$h) * 0.14d), 250, (Object) null);
                ASUI.UIZoom(this.val$txt, 110, 100, 250, (Object) null);
                new Handler().postDelayed(new Runnable(this, this.val$toast) {
                    private final AnonymousClass100000003 this$0;
                    private final Toast val$toast;

                    {
                        this.this$0 = r1;
                        this.val$toast = r2;
                    }

                    static AnonymousClass100000003 access$0(AnonymousClass100000002 r1) {
                        return r1.this$0;
                    }

                    @Override
                    public void run() {
                        this.val$toast.cancel();
                    }
                }, (long) 250);
            }
        }, (long) 2680);
        makeText.show();
    }

    public static boolean isArray(Object obj) {
        if (obj == null) {
            return false;
        }
        return obj.getClass().isArray();
    }

    public static String join(Collection collection, String str) {
        return join(collection.iterator(), str);
    }

    public static String join(Iterator it, String str) {
        if (!it.hasNext()) {
            return "";
        }
        String obj = it.next().toString();
        if (!it.hasNext()) {
            return obj;
        }
        StringBuilder append = new StringBuilder(64).append(obj);
        while (it.hasNext()) {
            append.append(str);
            append.append(it.next());
        }
        return append.toString();
    }

    public static String join(String[] strArr, String str) {
        return join((Collection) Arrays.asList(strArr), str);
    }

    public static void playmfunction(AssetFileDescriptor assetFileDescriptor, Object obj) {
        try {
            MediaPlayer mediaPlayer = new MediaPlayer();
            mediaPlayer.reset();
            mediaPlayer.setDataSource(assetFileDescriptor);
            if (obj != null) {
                mediaPlayer.setLooping(((Boolean) obj).booleanValue());
            }
            mediaPlayer.prepare();
            mediaPlayer.start();
        } catch (IOException | IllegalArgumentException | IllegalStateException | SecurityException e) {
        }
    }

    public static void push(Object[] objArr, Object obj) {
        int length = objArr.length;
        if (length >= 5) {
            ensureCapacity(objArr, length + 1, length);
        }
        setImpl(length, obj, objArr);
    }

    public static byte[] read(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] bArr = new byte[1024];
        while (inputStream.read(bArr) != -1) {
            try {
                byteArrayOutputStream.write(bArr);
            } catch (IOException e) {
            }
        }
        inputStream.close();
        return byteArrayOutputStream.toByteArray();
    }

    public static GradientDrawable roundBG(Object obj, Object obj2, String str, Object obj3) {
        if (!isArray(obj)) {
            return new roundRect(new Integer(Color.parseColor((String) obj)), obj2, str, obj3);
        }
        String[] strArr = (String[]) obj;
        int parseColor = Color.parseColor(strArr[0]);
        int parseColor2 = Color.parseColor(strArr[1]);
        return new roundRect(new int[]{parseColor, parseColor2}, obj2, strArr[2], new Integer(0));
    }

    public static void setImpl(int i, Object obj, Object[] objArr) {
        switch (i) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
                return;
            default:
                objArr[i - 5] = obj;
                return;
        }
    }
}
